/* 
 * File:   CrearDirectorioTest.cpp
 * Author: nahuel
 *
 * Created on Jun 4, 2013, 8:24:46 PM
 */

#include <stdlib.h>
#include <iostream>
#include "common_FileUtils.h"

/*
 * Simple C++ Test Suite
 */

using namespace TP::Archivos;

void testCrearDirectorio() {
    
    // Definir un path valido localmente
    const std::string path("/home/nahuel/Desktop/CrearDirectorioTest");    
    FileUtils fileUtils;    
    bool result = fileUtils.CrearDirectorio(path);
    
    if (!result) {
        std::cout << "%TEST_FAILED% time=0 testname=testCrearDirectorio (CrearDirectorioTest) message=error message sample" << std::endl;
    }
}

void testCalcularCantidadChunks(){
    std::cout << "FileUtils testCalcularCantidadChunks." << std::endl;
    
    FileUtils fileUtils;
    size_t cantidadChunks = fileUtils.CalcularCantidadChunks("/home/Max/facultad/gxemul/gxemul");
    
    if (cantidadChunks != 12)
    {
        std::cout << "%TEST_FAILED% time=0 testname=testCalcularCantidadChunks (CrearDirectorioTest) message=El numero de chunks computado no es el esperado." << std::endl;        
    }
}

void testGetHash(){

    std::cout << "FileUtils testGetHash." << std::endl;
    
    FileUtils fileUtils;
    //string hash = fileUtils.GetHash("/home/Max/testGetHash.txt", 0);
    string hash = fileUtils.GetHash("/home/Max/test/test_3.txt", 0);
    
    if ("9985c204968c40c2f0f2f22b262301ff" != hash)
    {
        std::cout << "%TEST_FAILED% time=0 testname=testGetHash (CrearDirectorioTest) message=El hash calculado no coincide con el hash esperado." << std::endl;        
    }
    
}

int main(int argc, char** argv) {
    
    std::cout << "%SUITE_STARTING% CrearDirectorioTest" << std::endl;
    std::cout << "%SUITE_STARTED%" << std::endl;

    std::cout << "%TEST_STARTED% testCalcularCantidadChunks (CrearDirectorioTest)" << std::endl;
    testCalcularCantidadChunks();
    std::cout << "%TEST_FINISHED% time=0 testCalcularCantidadChunks (CrearDirectorioTest)" << std::endl;

    std::cout << "%TEST_STARTED% testGetHash (CrearDirectorioTest)" << std::endl;
    testGetHash();
    std::cout << "%TEST_FINISHED% time=0 testGetHash (CrearDirectorioTest)" << std::endl;

    std::cout << "%SUITE_FINISHED% time=0" << std::endl;

    return (EXIT_SUCCESS);
}

